multistage pcy algorithm solved example